<script>

    $("#formtable").validator({
        submit: function() {
            if(this.isFormValid()) {
                var TradePrice = $('#TradePrice').val();
                var SuggestedPrice = $('#SuggestedPrice').val();
                var CustomTradePrice = $('#CustomTradePrice').val();
                var CustomSuggestedPrice = $('#CustomSuggestedPrice').val();
                var DepartmentId = $('#DepartmentId').val();
                var product_id = $('#product_id').val();
                $.post('', {'product_id':product_id, 'TradePrice':TradePrice, 'SuggestedPrice':SuggestedPrice,'CustomTradePrice':CustomTradePrice, 'CustomSuggestedPrice':CustomSuggestedPrice, 'DepartmentId':DepartmentId}, function(res){
                    if(res.code == 1) {
                        layer.alert(res.msg);return false;
                    }
                    parent.layer.closeAll();
                    parent.dialogReback();
                }, 'json');
            }
            return false;
        }
    });
    //设置门店列表
    get_manage_departments(function (d) {
        var opt = [];
        if (d.length > 0) {
            opt.push('<option value="">请选择</option>');
            $.each(d, function (idx, val) {
                opt.push('<option value="' + val.Id + '">' + val.Name + '</option>');
            });
        }
        $('#DepartmentId').html(opt.join(''));
    });
</script>